package multiThread.security;

/**
 * @projectName: java-sample
 * @description:
 * @author: Adam
 * @create: 2020-01-06 21:22
 **/

public class Thread1 extends Thread{

    public SecurityDemo securityDemo;

    public Thread1(){super();}

    public Thread1(SecurityDemo securityDemo){
        this.securityDemo = securityDemo;
    }

    @Override
    public void run() {
        /*while (true){
            if (securityDemo.getI()==10){
                System.out.println("i的值终于到了10了");
                break;
            }
        }*/
        //监听对象成员变量的变化
        while (securityDemo.getI()!=10){
            //Thread.sleep(1);
            System.out.println(Thread.currentThread().getName()+":"+securityDemo.getI());
        }
        System.out.println(Thread.currentThread().getName()+":i的值终于到了10了");
    }
}
